//样式transform切换
function transformAnimation(position1, speed1, id1) {
    $(id1).css({
        transform: "translateX(" + position1 + ")",
        WebkitTransform: "translateX(" + position1 + ")",
        WebkitTransition: "all " + speed1 + "ms ease",
        transition: "all " + speed1 + "ms ease"
    })
}
//模态框取消按钮函数
function dismiss() {
    $(".contain-no").click(function () {
        $(".contain-item").fadeOut();
        $(".contain-item1").fadeOut();
        $(".contain-item2").fadeOut();
    })
}

function loadCart(show, loaderid, bac) {
    var loader = document.getElementById(loaderid);
    if (!loader) {
        return;
    }
    var hei = $(window).height();
    var offHei = loader.style.top;
    loader.style.display = "flex";
    offHei = offHei.substring(0, offHei.length - 2);
    loader.style.height = (hei - offHei) + "px";
    if (show == true) {
        loader.style.zIndex = 1031;
        var loaderHtml = '';
        var spanLen = 12;
        loaderHtml += '<div class="loader-inner line-spin-fade-loader">'
        for (var i = 0; i < spanLen; i++) {
            loaderHtml += '<span></span>'
        }
        loaderHtml += '</div>';
        loader.innerHTML += loaderHtml;
        var spanDom = loader.getElementsByTagName("span");
        for (var j = 0; j < spanDom.length; j++) {
            var distance = 12;
            var angle = (360 / spanDom.length) * j;
            var _top = distance * Math.sin(2 * Math.PI * (angle / 360));
            var _left = distance * Math.cos(2 * Math.PI * (angle / 360));
            var infiniteTime = 0.08;
            setStyle(spanDom[j], {
                top: _top + "px",
                left: _left + "px",
                WebkitTransform: "rotate(" + angle + "deg)",
                //MsTransform: "rotate("+angle+"deg)",
                transform: "rotate(" + angle + "deg)",
                WebkitAnimation: "line-spin-fade-loader 0.96s " + infiniteTime * j + "s infinite ease-in-out",
                animation: "line-spin-fade-loader 0.96s " + infiniteTime * j + "s infinite ease-in-out",
                opacity: j * (1 / 18) + 0.3
            })
        }
        function setStyle(d, c) {
            for (name in c) {
                d.style[name] = c[name]
            }
        }
    } else {
        loader.style.zIndex = -1;
        if (bac) {
            var bacHtml = document.querySelector(bac).outerHTML;
            loader.innerHTML = bacHtml;
        } else {
            loader.innerHTML = '';
        }
    }
};
//输入框提示不同内容
function input_alert(html, time) {
    if (!time) {
        time = 2000;
    }
    var float_element = $(".c-float-popWrap")
    var hei = $(window).height() / 2
    var top = $(document).scrollTop() + hei - 30;
    float_element.css({"top": top + "px"})
    $(".warnMsg").html(html)
    float_element.show()
    setTimeout(function () {
        float_element.hide()
    }, time);
}
//判断手机操作系统类型和是否是微信环境
function environment_judge() {
    var environment = {
        isAndroid: false,
        isIOS: false,
        isWx: false
    };
    var u = navigator.userAgent, app = navigator.appVersion;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
    var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if (isAndroid) {
        environment.isAndroid = true;
    }
    if (isIOS) {
        environment.isIOS = true;
    }
    var ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
        environment.isWx = true;
    } else {
        environment.isWx = false;
    }
    return environment;
}
//自定义弹框
function confirm_box(id, act, sure, cancel) {
    if (act == "show") {
        id.show();
        $("#none").click(sure);
        $("#go").click(cancel);
    }
    else if (act == "hide") {
        id.hide();
    }
}